//
//  XXBaseNavigationController.swift
//  APP
//
//  Created by Rdxer on 2017/12/6.
//  Copyright © 2017年 Rdxer. All rights reserved.
//

import UIKit
import Async

open class XXBaseNavigationController: UINavigationController {
    deinit {
        XXLoger.w(self.classForCoder.description() + "已释放" )
    }
    
    open func prepareToPresent(){
        let image =  FastComponentBundle.imageWithSelf(name: "close")
        let goBackBarButton = UIBarButtonItem.init(image: image, style: .done, target: self, action: #selector(backItemPressed))
        viewControllers.first?.navigationItem.leftBarButtonItem = goBackBarButton
        self.modalPresentationStyle = .fullScreen
    }
    @objc open func backItemPressed() {
        self.dismiss(animated: true, completion: nil)
    }
    
    
    open override func viewDidLoad() {
        super.viewDidLoad()
        Async.main {
            XXLoger.w("已创建" + self.classForCoder.description() )
        }
        if #available(iOS 13.0, *) {
            let appearance = UINavigationBarAppearance.init()
            appearance.backgroundEffect = UIBlurEffect.init(style: UIBlurEffect.Style.regular)
            self.navigationBar.scrollEdgeAppearance = appearance
            //        appearance.backgroundEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleRegular];
            //        navigationController.scrollEdgeAppearance = appearance;
        } else {
            // Fallback on earlier versions
        };
    }
    
 
}
